/**
 * @program: LeetCode
 * @description: LeetCode : 55. 跳跃游戏
 * @author: WXY
 * @create: 2023-01-20 16:23
 * @Version 1.0
 **/
public class Num055_canJump_2 {
    public boolean canJump(int[] arr) {
        int maxLength = 0;
        if (arr.length == 1) return true;
        for (int i = 0; i <= maxLength; i++) {
            maxLength = Math.max(maxLength, i + arr[i]);
            if (maxLength>=arr.length - 1) return true;
        }
        return false;
    }
}
